package ch.ti.bfh.app.loodel.domain.timeslot;

import org.hibernate.validator.constraints.NotBlank;

import javax.persistence.Embeddable;

@Embeddable
public class Location {

    @NotBlank
    private String name;

    @NotBlank
    private String street;

    @NotBlank
    private String place;


    public Location(String name, String street, String place) {
        this.name = name;
        this.street = street;
        this.place = place;
    }

    /*
    * FOR JPA
     */
    protected Location() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Location)) return false;

        Location location = (Location) o;

        if (name != null ? !name.equals(location.name) : location.name != null) return false;
        if (place != null ? !place.equals(location.place) : location.place != null) return false;
        if (street != null ? !street.equals(location.street) : location.street != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + (street != null ? street.hashCode() : 0);
        result = 31 * result + (place != null ? place.hashCode() : 0);
        return result;
    }
}
